<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>

<form action="<?php echo url_for('portfolio/' . ($form->getObject()->isNew() ? 'create' : 'update') . (!$form->getObject()->isNew() ? '?id=' . $form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
    <?php if (!$form->getObject()->isNew()): ?>
        <input type="hidden" name="sf_method" value="put" />
    <?php endif; ?>
    <table>
        <tfoot>
            <tr>
                <td colspan="2">
                    &nbsp;<a href="<?php echo url_for('portfolio/index') ?>">Back to list</a>
                    <?php if (!$form->getObject()->isNew()): ?>
                        &nbsp;<?php echo link_to('Delete', 'portfolio/delete?id=' . $form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
                    <?php endif; ?>
                    <input type="submit" value="Save" />
                </td>
            </tr>
        </tfoot>
        <tbody>
            <?php //echo $form ?>
            <?php echo $form['title']->renderRow();?>
             <?php echo $form['slug']->renderRow();?>
                    <?php echo $form['about']->renderRow();?>
               <tr><th><label>Upload title image</label></th><td><div class="input_file" id="image_upload_wrapper">
                        <input type="file" class="add" onChange="return imageUploader.uploadImage(this, imageUploader.setImageUploaded,'portfolio','title');" 
                               id="title_image_upload_input" name="upload" />
                    </div></td></tr>
            <tr>
                <th><label>Title image</label></th><td>
                    <div id="title-image">

                        <?php if (isset($portfolio)) {
                            if ($image = $portfolio->getTitleImage()): ?>
                                <img id="<?php echo $image->getId() ?>" width="250" src="<?php echo image_path('/uploads/images/' . $image->getUri()); ?>">
                            <?php endif;
                        } ?>
                    </div>
                </td>
            </tr> 
            <tr><td></td><td></td></tr>
            <tr>
                <th><label>Upload main image</label></th><td><div class="input_file" id="image_upload_wrapper">
                        <input type="file" class="add" onChange="return imageUploader.uploadImage(this, imageUploader.setImageUploaded,'portfolio','main');" 
                               id="main_image_upload_input" name="upload"/>
                    </div></td>
            </tr>
            <tr>
                <th><label>Main page image</label></th><td>
                    <div id="main-image">
                        <?php if (isset($portfolio)) {
                            if ($main_image = $portfolio->getMainImage()): ?>
                                <img id="<?php echo $main_image->getId() ?>" width="250" src="<?php echo image_path('/uploads/images/' . $main_image->getUri()); ?>">
                            <?php endif;
                        } ?>
                    </div>
                </td>
            </tr>
                    <?php echo $form['title_image_id']->render();?>
                    <?php echo $form['main_image_id']->render();?>
                    <?php echo $form['id']->render();?>
                    <?php echo $form['solution_id']->render();?>
                     <?php echo $form['_csrf_token']->render(array('id'=>'csrf_token', 'class'=>'csrf_token')); ?>
        </tbody>
    </table>
</form>
